package com.fs.controller;

import java.math.BigInteger;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.fs.domain.ActivityCoupon;
import com.fs.service.IActivityCouponService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 优惠券管理Controller
 *
 * @author zh
 * @date 2024-10-18
 */
@RestController
@RequestMapping("/activity/activity")
public class ActivityCouponController extends BaseController {
    @Autowired
    private IActivityCouponService activityCouponService;

    /**
     * 查询优惠券管理列表
     */
    // @PreAuthorize("@ss.hasPermi('activity:activity:list')")
    @GetMapping("/list")
    public TableDataInfo list(ActivityCoupon activityCoupon) {
        startPage();
        List<ActivityCoupon> list = activityCouponService.selectActivityCouponList(activityCoupon);
        return getDataTable(list);
    }

    /**
     * 获取优惠券管理详细信息
     */
    // @PreAuthorize("@ss.hasPermi('activity:activity:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") BigInteger id) {
        return success(activityCouponService.selectActivityCouponById(id));
    }

    /**
     * 新增优惠券管理
     */
    // @PreAuthorize("@ss.hasPermi('activity:activity:add')")
    @Log(title = "优惠券管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ActivityCoupon activityCoupon) {
        return toAjax(activityCouponService.insertActivityCoupon(activityCoupon));
    }

    /**
     * 修改优惠券管理
     */
    // @PreAuthorize("@ss.hasPermi('activity:activity:edit')")
    @Log(title = "优惠券管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ActivityCoupon activityCoupon) {
        return toAjax(activityCouponService.updateActivityCoupon(activityCoupon));
    }

    /**
     * 删除优惠券管理
     */
    // @PreAuthorize("@ss.hasPermi('activity:activity:remove')")
    @Log(title = "优惠券管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{id}")
    public AjaxResult remove(@PathVariable("id") BigInteger id) {
        return toAjax(activityCouponService.deleteActivityCouponById(id));
    }
}
